package com.codi.api.controller;

import com.codi.api.security.UserUtil;
import com.codi.bus.constant.GlobalConstant;
import com.codi.bus.core.domain.UserFeedback;
import com.codi.bus.core.resultModel.BaseResult;
import com.codi.bus.core.service.UserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;

/**
 * @DESCRIBE
 * @Author sungaoxiang [sungaoxiang@cd121.com]
 * @DATE 2017/10/13 17:40
 **/
@RestController
@RequestMapping("/feedback")
public class FeedbackController {

    @Autowired
    private UserFeedbackService userFeedbackService;

    @RequestMapping(value = "add",method = RequestMethod.POST)
    public BaseResult add(@RequestHeader(GlobalConstant.HEADER_AUTH_TOKEN) String token,
                          @RequestParam String feedbackContent, UserFeedback model) throws UnsupportedEncodingException {
        Long userId = UserUtil.getLoginUserId();
        model.setUserId(userId);
        return userFeedbackService.addFeedback(model);
    }
}
